﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace game
{
    [StructLayout(LayoutKind.Sequential)]
    public struct BillboardParticleVertex
    {
        public Vector3 InitialPosition;
        public Vector2 TexCoord;
        public Vector2 Offset;
        public Vector3 Velocity;
        public float InitialTimeMs;
        public float DieTimeMs;
        public Vector3 Axis;
        public Color InitialColor;

        public static VertexElement[] VertexElements;
        public static VertexDeclaration VertexDecl;
        public static int SizeInBytes { get; private set; }

        static BillboardParticleVertex()
        {
            VertexElements = new VertexElement[] { // must have the same format as Particle struct
                    new VertexElement(0, 0, VertexElementFormat.Vector3, VertexElementMethod.Default, VertexElementUsage.Position, 0),
                    new VertexElement(0, 12, VertexElementFormat.Vector2, VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, 0),
                    new VertexElement(0, 20, VertexElementFormat.Vector2, VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, 1),
                    new VertexElement(0, 28, VertexElementFormat.Vector3, VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, 2),
                    new VertexElement(0, 40, VertexElementFormat.Single, VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, 3),
                    new VertexElement(0, 44, VertexElementFormat.Single, VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, 4),
                    new VertexElement(0, 48, VertexElementFormat.Vector3, VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, 5),
                    new VertexElement(0, 60, VertexElementFormat.Color, VertexElementMethod.Default, VertexElementUsage.Color, 0) 
                };

            VertexDecl = new VertexDeclaration(ShooterGame.Instance.GraphicsDevice, VertexElements);

            SizeInBytes = 12 + 8 + 8 + 12 + 4 + 4 + 12 + 4;
        }
    }
}
